import React, { useState } from 'react'

import {
    importsExcel, //导入
    exportExcel //导出
} from '../../untils'

export default function Excel() {
    const [header, ActioHeader] = useState([
        {
            title: '编号',
            dataIndex: 'id',
            key: 'id',
            className: 'text-monospace',
        }, {
            title: '用户名称',
            dataIndex: 'username',
            key: 'username',
        }, {
            title: '用户年龄',
            dataIndex: 'userage',
            key: 'userage',
        }
    ])
    const [excelList, actionExcelList] = useState([
        {
            id: 1,
            username: "leson",
            userage: 18
        },
        {
            id: 2,
            username: "lulu",
            userage: 30
        },
        {
            id: 3,
            username: "beibei",
            userage: 19
        }]
    )
    return (
        <div>
            周考成绩
            <input type="file" accept=".xls,.xlsx" onChange={(e) => {
                importsExcel(e).then(function (data) {
                    console.log(data);
                    // actionList(data);
                }, function (data) {
                    console.log(data);
                })
            }} />
            <button onClick={
                () => {
                    exportExcel(header, excelList, "学生信息.xlsx")
                }
            }>导出excel数据</button>
        </div>
    )
}
